package com.kehao.leetcode.hard.sort_search;

import com.kehao.utils.LeetCodeUtil;
import org.junit.Test;

import java.util.PriorityQueue;
import java.util.concurrent.ForkJoinPool;

public class kthSmallestSolution {
    public int kthSmallest(int[][] matrix, int k) {
        PriorityQueue<Integer> queue = new PriorityQueue<>();
        for (int i = 0; i < matrix.length; i++) {
            for (int j = 0; j < matrix[0].length; j++) {
                queue.add(matrix[i][j]);
            }
        }
        int result = 0;
        for (int i = 0; i < k; i++) {
            result = queue.poll();
        }
        return result;
    }

    @Test
    public void test(){
        System.out.println(LeetCodeUtil.bracketTransform("matrix = [[1,5,9],[10,11,13],[12,13,15]]"));
    }

    @Test
    public void test01(){
        int[][] matrix = {{1,5,9},{10,11,13},{12,13,15}};
        System.out.println(kthSmallest(matrix, 8));
    }
}
